﻿<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title>订单列表</title>
    <link href="/style/rightdirectory.css" rel="stylesheet" />
    <script src="/script/config.js"></script>
</head>
<style>
    th {
        text-align: center;
    }

    td {
        text-align: center;
    }

    .detail {
        color: darkcyan;
    }
</style>
<body>
    <div class="view-page">
        <!--搜索区域-->
        <div class="view-search inline">
            <div class="form-inline">
                <div class="form-group col-sm-2">
                    <div class="input-group">
                        <span class="input-group-addon">顾客名称</span>
                        <input id="query" type="text" class="form-control" data-form="CustomerName" placeholder="顾客名称">
                    </div>
                </div>

                <div class="form-group col-sm-2">
                    <div class="input-group">
                        <span class="input-group-addon">订单名称</span>
                        <input id="query3" type="text" class="form-control" data-form="OrderNo" placeholder="订单名称">
                    </div>
                </div>

                <div class="form-group col-sm-2">
                    <div class="input-group">
                        <span class="input-group-addon">状态</span>
                        <select class="form-control" id="PutawayState" data-form="Status" value="" placeholder="订单状态">
                            <option value="">订单状态</option>
                            <option value="1">待支款</option>
                            <option value="2">待发货</option>
                            <option value="3">待收货</option>
                            <option value="4">待评价</option>
                            <option value="5">已完成</option>
                            <option value="-2">退货</option>
                        </select>
                    </div>
                </div>
                <div class="form-group col-sm-1">
                    <button type="button" id="btn-search" class="btn btn-primary">
                        <i class="fa fa-search"></i> 搜索
                    </button>
                </div>
            </div>
        </div>

        <div class="view-eidt-btns">
            <a href="javascript:;" class="btn btn-sm" data-btn-eidt="" id="delivery">
                <i class="fa fa-edit"></i>发货
            </a>
            <a href="javascript:;" class="btn btn-sm">
                <i class="fa fa-plus"></i>批量发货
            </a>
            <a href="javascript:;" class="btn btn-sm" id="present">
                <i class="icon icon-gift"></i>赠送
            </a>

            <a href="javascript:;" class="btn btn-sm" id="batchOrderPrint">
                <i class="icon icon-print"></i>批量打印
            </a>
            <a href="javascript:;" class="btn btn-sm" id="batchLogisticsOrderPrint">
                <i class="icon icon-print"></i>批量快递单打印
            </a>
        </div>

        <div class="view-data">
            <table id="table" class="table table-bordered table-hover" data-post="">
                <thead>
                    <tr>
                        <th>FH</th>
                        <th>订单号</th>
                        <th>顾客名称</th>
                        <th>快递单号</th>
                        <th>快递方式</th>
                        <th>支付方式</th>
                        <th>产品数量</th>
                        <th>订单总额</th>
                        <th>美豆抵扣</th>
                        <th>支付额度</th>
                        <th>订单状态</th>
                        <th>支付时间</th>
                        <th>发货时间</th>
                        <th>收货时间</th>
                        <th>创建时间</th>
                        <th>是否赠送</th>
                    </tr>
                </thead>
                <tbody></tbody>
            </table>
            <!--分页条 默认选择id=list-page元素-->
            <div id="list-page" class="view-pagination-page"></div>
        </div>
    </div>
</body>

</html>
<script type="text/html" id="tp-table">
    {{each list d}}
    <tr data-eidt="{{d.OrderNo}}">
        <td class="checkboxs">
            <label class="checkbox-reset">
                <input type="checkbox" value="{{d.OrderNo}}" data-checked-table="single" />
            </label>
        </td>
        <td><a class="detail" href="javascript:;" onclick="openDetail('{{d.OrderNo}}')">{{d.OrderNo}}</a></td>
        <td>{{d.RealName}}</td>
        <td>{{d.LogisticsNo}}</td>
        <td>{{d.LogisticsName}}</td>
        <td>{{d.PayName}}</td>
        <td>{{d.Products}}</td>
        <td>{{d.OrderPrice}}</td>
        <td>{{d.MeiBean}}</td>
        <td>{{d.PayPrice}}</td>
        {{if d.Status==1}}
        <td>待付款</td>
        {{else if d.Status==2}}
        <td>待发货</td>
        {{else if d.Status==3}}
        <td>待收货</td>
        {{else if d.Status==4}}
        <td>待评价</td>
        {{else if d.Status==5}}
        <td>已完成</td>
        {{else if d.Status==-1}}
        <td>订单关闭</td>
        {{else if d.Status==-2}}
        <td>订单退货</td>
        {{/if}}
        <td>{{d.PayDate|to_date}}</td>

        <td>{{d.DeliveryDate|to_date}}</td>
        <td>{{d.TakeDeliveryDate|to_date}}</td>
        <td>{{d.CreateDate|to_date}}</td>
        {{if d.HasPresent=="true"}}
        <td><span class="label label-danger">赠送</span></td>
        {{else}}
        <td><span class="label">没有</span></td>
        {{/if}}
    </tr>
    {{/each}}
</script>
<script src="/script/plugins/print/LodopFuncs.js"></script>
<script type="text/html" id="tp-order-detail">
    <div id="layre-order-detail" style="padding:10px">
        <div class="panel" id="tem">
            <div class="panel-heading">订单详细<button class="btn" onclick="CreatePrintPage()" style="padding: 0px 12px; float:right;" type="button"><i class="icon icon-print"></i> 打印</button></div>
            <div class="panel-body">
                <table class="table table-bordered">
                    <thead>
                        <tr>
                            <th>订单号</th>
                            <th>产品名称</th>
                            <th>购买数量</th>
                            <th>产品总额</th>
                            <th>产品SKU名称 </th>
                            <th>创建时间</th>
                        </tr>
                    </thead>
                    <tbody></tbody>
                </table>
            </div>
        </div>
        <div class="panel" id="tem1">
            <div class="panel-heading">订单产品</div>
            <div class="panel-body">
                <table class="table table-bordered">
                    <thead>
                        <tr>
                            <th>推荐id</th>
                            <th>顾客</th>
                            <th>产品总量</th>
                            <th>原价总额</th>
                            <th>支付总额</th>
                            <th>快递方式</th>
                            <th>快递单号</th>
                            <th>支付方式</th>
                            <th>状态</th>
                            <th>支付时间</th>
                            <th>发货时间</th>
                            <th>收货时间</th>
                            <th>评价时间</th>
                            <th>创建时间</th>
                        </tr>
                    </thead>
                    <tbody></tbody>
                </table>
            </div>
        </div>
        <div class="panel" id="tem2">
            <div class="panel-heading">收货信息</div>
            <div class="panel-body">
                <table class="table table-bordered">
                    <thead>
                        <tr>
                            <th>收货人姓名</th>
                            <th>电话</th>
                            <th>邮编</th>
                            <th>省份</th>
                            <th>市</th>
                            <th>区、县</th>
                            <th>详细地址</th>
                        </tr>
                    </thead>
                    <tbody></tbody>
                </table>
            </div>
        </div>
        <div class="panel" id="tem3">
            <div class="panel-heading">赠送产品</div>
            <div class="panel-body">
                <table class="table table-bordered">
                    <thead>
                        <tr>
                            <th>产品名称</th>
                            <th>产品SKU名称</th>
                            <th>数量</th>
                        </tr>
                    </thead>
                    <tbody></tbody>
                </table>
            </div>
        </div>
    </div>
</script>

<script type="text/html" id="det-temp">
    {{each list.OrderInfoList d}}
    <tr>
        <td>{{d.OrderNo}}</td>
        <td>{{d.ProductName}}</td>
        <td>{{d.BuyNumber}}</td>
        <td>{{d.BuySumPrice}}</td>
        <td>{{d.SkuPropertyName}}</td>
        <td>{{d.CreateDate|to_date}}</td>
    </tr>
    {{/each}}
</script>


<script type="text/html" id="com-temp">
    {{set t=list.vOrder}}
    <tr>
        <td>{{t.ReferrerId}}</td>
        <td>{{t.CustomerName}}</td>
        <td>{{t.Products}}</td>
        <td>{{t.OriginalPrice}}</td>
        <td>{{t.PayPrice}}</td>
        <td>{{t.LogisticsName}}</td>
        <td>{{t.LogisticsNo}}</td>
        <td>{{t.PayName}}</td>
        {{if t.Status==1}}
        <td>待付款</td>
        {{else if t.Status==2}}
        <td>待发货</td>
        {{else if t.Status==3}}
        <td>待收货</td>
        {{else if t.Status==4}}
        <td>待评价</td>
        {{else if t.Status==5}}
        <td>已完成</td>
        {{else if t.Status==-1}}
        <td>订单关闭</td>
        {{/if}}
        <td>{{t.PayDate|to_date}}</td>
        <td>{{t.DeliveryDate|to_date}}</td>
        <td>{{t.TakeDeliveryDate|to_date}}</td>
        <td>{{t.EstimateDate|to_date}}</td>
        <td>{{t.CreateDate|to_date}}</td>
    </tr>
</script>

<script type="text/html" id="com-temp2">
    {{set t=list.vOrder}}
    <tr>
        <td>{{t.RealName}}</td>
        <td>{{t.Phone}}</td>
        <td>{{t.PostCode}}</td>
        <td>{{t.Province}}</td>
        <td>{{t.City}}</td>
        <td>{{t.Area}}</td>
        <td>{{t.AddressDetail}}</td>
    </tr>
</script>
<script type="text/html" id="com-temp3">
    {{each list.OrderPresentProductInfo d}}
    <tr>
        <td>{{d.ProductName}}</td>
        <td>{{d.SkuName}}</td>
        <td>{{d.Number}}</td>
    </tr>
    {{/each}}
</script>

<!-- 发货 -->
<script type="text/html" id="fahou">
    <div style="padding:10px;" id="temfahou">
        <div class="form-horizontal " style="padding-top:10px;">

            <div class="form-group">
                <label class="col-sm-3">订单号</label>
                <div class="col-md-6 col-sm-8">
                    <input type="text" class="form-control" readonly maxlength="50" data-form="OrderNo" placeholder="订单号" value="{{OrderNo}}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3">快递号</label>
                <div class="col-md-6 col-sm-8">
                    <input type="text" class="form-control" maxlength="40" data-form="LogisticsNo" placeholder="快递号" value="{{LogisticsNo}}">
                </div>
            </div>


            <div id="wuliu">
                <div class="form-group">
                    <label class="col-sm-3">物流公司名称</label>
                    <div class="col-md-6 col-sm-8">
                        <select class="form-control enrich-drop-down" data-form="LogisticsName" value="{{LogisticsName}}">
                            <option value="">请选择类型</option>
                            {{each install item}}
                            <option value="{{item.LogisticsName}}" {{if item.LogisticsName==LogisticsName}} selected {{/if}}>{{item.LogisticsName}} </option>
                            {{/each}}
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3">物流公司编号</label>
                    <div class="col-md-6 col-sm-8">
                        <select class="form-control enrich-drop-down" data-form="LogisticsCode" value="{{LogisticsCode}}">
                            <option value="">请选择类型</option>
                            {{each install item}}
                            <option value="{{item.LogisticsCode}}" {{if item.LogisticsCode==LogisticsCode}} selected {{/if}}>{{item.LogisticsCode}} </option>
                            {{/each}}
                        </select>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <div class="col-sm-offset-5 col-sm-3">
                    <button type="button" id="btn-submit" class="btn btn-primary ">发货</button>
                </div>
            </div>
        </div>
    </div>
</script>

<script type="text/html" id="persentform">
    <div style="padding:10px;" id="tempersent">
        <div class="form-horizontal " style="padding-top:10px;">
            <div class="form-group">
                <label class="col-sm-3">订单号</label>
                <div class="col-md-6 col-sm-8">
                    <input type="text" class="form-control" maxlength="50" id="persentOrderNo" placeholder="订单号" value="{{OrderNo}}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3">赠送内容</label>
                <div class="col-md-3 col-sm-4">
                    <select class="form-control" id="persentContent">
                        <option value="爱奇艺视频会员">爱奇艺视频会员</option>
                        <option value="优酷视频会员">优酷视频会员</option>
                        <option value="腾讯视频会员">腾讯视频会员</option>
                        <option value="芒果TV会员">芒果TV会员</option>
                    </select>
                </div>

                <div class="col-md-3 col-sm-4">
                    <select class="form-control" id="persentContent2">
                        <option value="一个月">一个月</option>
                        <option value="两个月">两个月</option>
                        <option value="三个月">三个月</option>
                        <option value="四个月">四个月</option>
                        <option value="五个月">五个月</option>
                        <option value="六个月">六个月</option>
                        <option value="七个月">七个月</option>
                        <option value="八个月">八个月</option>
                        <option value="九个月">九个月</option>
                        <option value="十个月">十个月</option>
                        <option value="十一个月">十一个月</option>
                        <option value="一年">一年</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3">赠送数量</label>
                <div class="col-md-6 col-sm-8">
                    <input type="text" class="form-control" maxlength="50" id="persentnumber" placeholder="赠送数量" value="1">
                </div>
            </div>

            <div class="form-group">
                <div class="col-sm-offset-5 col-sm-3">
                    <button type="button" id="btn-submitpersent" class="btn btn-primary ">赠送</button>
                </div>
            </div>
        </div>
    </div>
</script>
<link href="/script/valid/css/tr.css" rel="stylesheet" /><!--判断如：PlatformName格式-->
<script src="/script/valid/form-valid.js?v=2018"></script>

<script type="text/javascript">
    var LODOP;
    var index = 0;
    $(function () {
        function _LoadData() {
            var parm = $(".view-search").getFormData();
            $("#table").ajaxPageTable("order/list",
                parm,
                function(d) {
                    $("#table>tbody").append(template("tp-table",
                        {
                            list: d
                        }));
                });
        }

        _LoadData(); //初启化
        $(".form-control").focus(function () { //搜索按钮
            $(".form-control").keydown(function (e) {
                if (e.keyCode == 13) {
                    _LoadData();
                }
            })
        })
        $("#btn-search").click(function () { //搜索按钮
            _LoadData();
        })

        //发货
        $("#delivery").click(function () {
            var checkbox = $("#table").getTableChecked({ type: {} });
            if (checkbox.length <= 0 || checkbox.length > 1) {
                $.msgFall("请选择一个发货！");
                return;
            }
            checkbox = checkbox.join("");
            $.layrePage({ //弹出
                area: ["40%", "400px"],
                title: "发货",
                offset: "6px",
                content: template("fahou", {})
            });
            $.http.json("logisticsvconfig/list",
                { Page: { Index: 1 } },
                {
                    pass: function (data) {
                        wuliu(data.Data, checkbox);
                    }
                });
            return;
        });
        $("#present").click(function () {
            var checkbox = $("#table").getTableChecked({ type: {} });
            if (checkbox.length <= 0) {
                $.msgFall("请选择一个订单！");
                return;
            }
            checkbox = checkbox.join(",");
            index = $.layrePage({ //弹出
                area: ["40%", "300px"],
                title: "赠送",
                offset: "6px",
                content: template("persentform", { OrderNo: checkbox }),
                success: function () {
                    $("#btn-submitpersent").click(function () {

                        var checkbox = $("#table").getTableChecked({ type: {} });
                        var persentContent = $("#persentContent").val();
                        var persentContent2 = $("#persentContent2").val();
                        var persentnumber = $("#persentnumber").val();
                        $.http.request(
                            "orderpresent/insert2",
                            { Orders: checkbox, Content: persentContent + persentContent2, Number: persentnumber },
                            {
                                pass: function (d, status, xhr) {
                                    if (d.Errcode == 0) {
                                        $.msgSucceed(d.Errmsg);
                                        $.layreClose(index);
                                    } else {
                                        $.msgFall(d.Errmsg);
                                    }
                                }
                            }
                        );
                    });
                }
            });
        });

        //批量打印
        $("#batchOrderPrint").click(function () {
            var checkbox = $("#table").getTableChecked({ type: {} });
            $.http.json("order/print/list", { Orders: checkbox }, { //发出请求
                pass: function (d) {
                    var list = [];
                    var OrderList = [];
                    var tempList = [];
                    for (var i = 0; i < d.OrderList.length; i++) {
                        var status = 0;
                        var mergeNo = "";
                        var tempOrderList = [];
                        var isMerge=0
                        //判断是否已经被同一批订单合并了
                        for (var j = 0; j < tempList.length; j++) {
                            if (d.OrderList[i].OrderNo == tempList[j]) {
                                isMerge = 1;
                                break;
                            }
                        }
                        if (isMerge == 1) {
                            continue;
                        }
                        //判断赠品中的合并订单号
                        for (var j = 0; j < d.OrderPresentProductInfo.length; j++) {
                            if (d.OrderList[i].OrderNo == d.OrderPresentProductInfo[j].OrderNo) {
                                status = 1;
                                mergeNo = d.OrderPresentProductInfo[j].OrderMergeNo;
                            }
                        }
                        //判断是否是赠品

                        if (status == 1) {
                            var products = 0;
                            var payPrice = 0;
                            tempList = [];
                            $.each(d.OrderPresentProductInfo, function (j, jitem) {
                                if (mergeNo == jitem.OrderMergeNo) {
                                    tempList.push(jitem.OrderNo);
                                }
                            });
                            $.each(d.OrderList, function (j, jitem) {
                                $.each(tempList, function (k, kitem) {
                                    if (kitem == jitem.OrderNo) {
                                        tempOrderList.push(jitem);
                                        products += jitem.Products;
                                        payPrice += jitem.PayPrice;
                                    }
                                });
                            });
                            var obj = tempOrderList[0];
                            obj.Products = products;
                            obj.PayPrice = payPrice;
                            obj["Remark"] = "本订单是多个订单合并【"+tempList.join()+"】";
                            //合并订单详情和赠送
                            $.each(d.OrderInfoList, function (j, jitem) {
                                $.each(tempList, function (k, kitem) {
                                    if (kitem == jitem.OrderNo) {
                                        jitem.OrderNo = obj.OrderNo;
                                    }
                                });
                            });
                            $.each(d.OrderPresentProductInfo, function (j, jitem) {
                                $.each(tempList, function (k, kitem) {
                                    if (kitem == jitem.OrderNo) {
                                        jitem.OrderNo = obj.OrderNo;
                                    }
                                });
                            });
                            OrderList.push(obj);
                            status = 0;
                        } else {
                            OrderList.push(d.OrderList[i]);
                        }
                    }
                    d.OrderList = OrderList;
                    $.each(d.OrderList, function(i, item) {
                        var data = { OrderInfo: [], OrderPresentProductInfo:[]};
                        data["Order"] = item;
                        $.each(d.OrderInfoList, function (j, jitem) {
                            if (jitem.OrderNo == item.OrderNo) {
                                data["OrderInfo"].push(jitem);
                            }
                        });
                        $.each(d.OrderPresentProductInfo, function (j, jitem) {
                            if (jitem.OrderNo == item.OrderNo) {
                                data["OrderPresentProductInfo"].push(jitem);
                            }
                        });
                        list.push(data);
                    });
                    $.each(list, function (i, item) {
                        batchPrintTemplate(list[i]);
                    });
                },
                error: function (d) {
                    console.log(d)
                }
            })
        });

        //批量快递单打印
        $("#batchLogisticsOrderPrint").click(function() {
            $.http.json("logistics/dzmd", {  }, { //发出请求
                pass: function (d) {
                    console.log(d);
                },
                error: function (d) {

                }
            });
        });
    });
    //批量打印模板
    function batchPrintTemplate(data) {
        
        var top = 0;
        var sum = 0;
        LODOP = getLodop();
        LODOP.PRINT_INIT("送货订单");
        LODOP.SET_PRINT_STYLEA("FontName", "隶书");
        LODOP.SET_PRINT_STYLE("FontSize", 12);
        LODOP.ADD_PRINT_TEXT("10mm", "5mm", "140mm", "10mm", "订单编号：" + data.Order.OrderNo);
        LODOP.ADD_PRINT_TEXT("10mm", "70mm", "140mm", "10mm", "下单时间：" + data.Order.CancelDate);
        LODOP.ADD_PRINT_TEXT("20mm", "5mm", "105mm", "10mm", "产品名称");
        LODOP.ADD_PRINT_TEXT("20mm", "110mm", "15mm", "10mm", "数量");
        LODOP.ADD_PRINT_TEXT("20mm", "125mm", "20mm", "10mm", "金额");

        LODOP.ADD_PRINT_TEXT("25mm", "5mm", "140mm", "10mm", "-----------------------------------------------------------------");
        top = 25;
        $.each(data.OrderInfo, function (i, item) {
            LODOP.ADD_PRINT_TEXT((top + 5) + "mm", "5mm", "105mm", "10mm", item.ProductName + "(" + item.SkuPropertyName + ")");
            LODOP.SET_PRINT_STYLEA(0, "FontSize", 10);
            LODOP.ADD_PRINT_TEXT((top + 5) + "mm", "110mm", "15mm", "10mm", item.BuyNumber);
            LODOP.ADD_PRINT_TEXT((top + 5) + "mm", "125mm", "20mm", "10mm", item.BuySumPrice);
            top = top + 5;
            sum = sum + parseFloat(item.BuySumPrice);
        });
        top = top + 5;
        LODOP.ADD_PRINT_TEXT(top + "mm", "5mm", "140mm", "10mm", "-----------------------------------------------------------------");
        top = top + 5;
        LODOP.ADD_PRINT_TEXT(top + "mm", "5mm", "140mm", "10mm", "合计：    " + sum + "元");
        if (data.OrderPresentProductInfo.length > 0) {
            top = top + 5;
            LODOP.ADD_PRINT_TEXT(top + "mm", "5mm", "140mm", "10mm", "-----------------------------赠送产品----------------------------");
            $.each(data.OrderPresentProductInfo, function (i, item) {
                LODOP.ADD_PRINT_TEXT((top + 5) + "mm", "5mm", "105mm", "10mm", item.ProductName + "(" + item.SkuProperty + ")");
                LODOP.SET_PRINT_STYLEA(0, "FontSize", 10);
                LODOP.ADD_PRINT_TEXT((top + 5) + "mm", "110mm", "15mm", "10mm", item.Number);
                top = top + 5;
            });
            top = top + 5;
            LODOP.ADD_PRINT_TEXT(top + "mm", "5mm", "140mm", "10mm", "-----------------------------------------------------------------");
        }
        top = top + 15;
        LODOP.ADD_PRINT_TEXT(top + "mm", "5mm", "140mm", "10mm", "----------------------------收货人信息---------------------------");
        top = top + 5;
        LODOP.ADD_PRINT_TEXT(top + "mm", "5mm", "140mm", "10mm", "收货人姓名：" + data.Order.RealName);
        top = top + 5;
        LODOP.ADD_PRINT_TEXT(top + "mm", "5mm", "140mm", "10mm", "收货人电话：" + data.Order.Phone);
        top = top + 5;
        var address = data.Order.Province + data.Order.City + data.Order.Area;
        LODOP.ADD_PRINT_TEXT(top + "mm", "5mm", "140mm", "10mm", "收货人地址：" + address);
        top = top + 5;
        LODOP.ADD_PRINT_TEXT(top + "mm", "5mm", "140mm", "10mm", "收货人详细地址：" + data.Order.AddressDetail);
        top = top + 15;
        LODOP.ADD_PRINT_TEXT(top + "mm", "5mm", "140mm", "10mm", "备注：" + data.Order.Remark);
        LODOP.PREVIEW();
    }

    function ExpressagePrint() {

        LODOP = getLodop();
        LODOP.PRINT_INITA(0, 0, 760, 731, "快递单打印");
        LODOP.SET_PRINT_MODE("PRINT_NOCOLLATE", 1);
        LODOP.ADD_PRINT_TEXT("0mm", "30mm", "53mm", "14mm", "\r\n               代收货款：￥ 300");
        LODOP.ADD_PRINT_SHAPE(4, "0mm", "83mm", "17.01mm", "14mm", 0, 1, "#000000");
        LODOP.ADD_PRINT_TEXT(6, 325, 53, 45, "代收\r\n货款");
        LODOP.SET_PRINT_STYLEA(0, "FontSize", 12);
        LODOP.SET_PRINT_STYLEA(0, "FontColor", "#FFFFFF");
        LODOP.ADD_PRINT_RECT("14mm", "-2.12mm", "102.76mm", "15mm", 0, 1);
        LODOP.ADD_PRINT_TEXT(56, 41, 322, 47, "888-888-888");
        LODOP.SET_PRINT_STYLEA(0, "FontSize", 39);
        LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
        LODOP.ADD_PRINT_RECT("29mm", "-2.01mm", "103.03mm", "10mm", 0, 1);
        LODOP.ADD_PRINT_BARCODE("30mm", "68.18mm", "35mm", "7.99mm", "Code39", "123456789012");
        LODOP.SET_PRINT_STYLEA(0, "ShowBarText", 0);
        LODOP.ADD_PRINT_RECT("38.74mm", "-1.01mm", "102mm", "15mm", 0, 1);
        LODOP.ADD_PRINT_TEXT(165, "2.01mm", 23, 20, "收");
        LODOP.SET_PRINT_STYLEA(0, "FontSize", 10);
        LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
        LODOP.ADD_PRINT_TEXT("41.99mm", "10mm", "20mm", "5.29mm", "刘洪涛");
        LODOP.SET_PRINT_STYLEA(0, "FontSize", 10);
        LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
        LODOP.ADD_PRINT_TEXT("41.99mm", "30mm", "70.01mm", "5.29mm", "13725243671");
        LODOP.SET_PRINT_STYLEA(0, "FontSize", 10);
        LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
        LODOP.ADD_PRINT_TEXT(178, 38, 339, 22, "广州市白云区云城西路北今尚科技大厦A栋一楼");
        LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
        LODOP.ADD_PRINT_RECT("53.71mm", "-0.74mm", "102mm", "12.01mm", 0, 1);
        LODOP.ADD_PRINT_TEXT(216, "2.01mm", 24, 20, "寄");
        LODOP.SET_PRINT_STYLEA(0, "FontSize", 10);
        LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
        LODOP.ADD_PRINT_TEXT("55.01mm", "10mm", "20mm", "5.29mm", "马云");
        LODOP.ADD_PRINT_TEXT("55.01mm", "30mm", "70.01mm", "5.29mm", "88888888888888");
        LODOP.ADD_PRINT_TEXT("59mm", 38, 339, 25, "杭州阿里巴巴总部");
        LODOP.SET_PRINT_STYLEA(0, "LineSpacing", -1);
        LODOP.ADD_PRINT_RECT("65.7mm", "-1.01mm", "102mm", "22.99mm", 0, 1);
        LODOP.ADD_PRINT_BARCODE("69.9mm", "5.58mm", "94.01mm", "15mm", "Code93", "AFC7150124715012425524");
        LODOP.ADD_PRINT_RECT("88.69mm", "-1.01mm", "102mm", "22.99mm", 0, 1);
        LODOP.ADD_PRINT_TEXT(339, 0, "20mm", 30, " 2018/09/03\r\n  10:04:23");
        LODOP.SET_PRINT_STYLEA(0, "FontSize", 8);
        LODOP.ADD_PRINT_TEXT(369, "0mm", "20mm", 15, " 打印时间");
        LODOP.SET_PRINT_STYLEA(0, "FontSize", 8);
        LODOP.ADD_PRINT_TEXT(386, 0, "20mm", 20, " 数量:20");
        LODOP.SET_PRINT_STYLEA(0, "FontSize", 8);
        LODOP.ADD_PRINT_TEXT(399, 0, "20mm", 15, " 重量:1.6kg");
        LODOP.SET_PRINT_STYLEA(0, "FontSize", 8);
        LODOP.ADD_PRINT_RECT("88.69mm", "20mm", "60.01mm", "22.99mm", 0, 1);
        LODOP.ADD_PRINT_TEXT("90.54mm", 79, 222, 57, "快件送达收件人地址,经收件人活收件人(寄件人)允许的代收人签...(省略)");
        LODOP.SET_PRINT_STYLEA(0, "FontSize", 7);
        LODOP.ADD_PRINT_TEXT(400, 173, 100, 15, "签收栏：");
        LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
        LODOP.ADD_PRINT_SHAPE(2, "89.48mm", "81.33mm", "20mm", "20mm", 0, 1, "#FFFFFF");
        LODOP.ADD_PRINT_RECT("111.68mm", "-1.01mm", "102mm", "10mm", 0, 1);
        LODOP.ADD_PRINT_BARCODE("113.14mm", 166, "60.01mm", "7.99mm", "Code93", "123456789012");
        LODOP.SET_PRINT_STYLEA(0, "FontSize", 7);
        LODOP.ADD_PRINT_BARCODE(346, 309, "20mm", "20mm", "QRCode", "123456789012");
        LODOP.ADD_PRINT_RECT("121.68mm", "-1.01mm", "80.99mm", "10mm", 0, 1);
        LODOP.ADD_PRINT_RECT("131.68mm", "-1.01mm", "80.99mm", "10mm", 0, 1);
        LODOP.ADD_PRINT_RECT("121.68mm", "80.01mm", "22.99mm", "20mm", 0, 1);
        LODOP.ADD_PRINT_BARCODE("123.64mm", 306, "20mm", "20mm", "QRCode", "123456789012");
        LODOP.ADD_PRINT_TEXT(468, "1.75mm", 25, 20, "收");
        LODOP.SET_PRINT_STYLEA(0, "FontSize", 10);
        LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
        LODOP.ADD_PRINT_TEXT(507, "1.48mm", 28, 20, "寄");
        LODOP.SET_PRINT_STYLEA(0, "FontSize", 10);
        LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
        LODOP.ADD_PRINT_TEXT(463, "10mm", "20mm", 20, "刘洪涛");
        LODOP.SET_PRINT_STYLEA(0, "FontSize", 7);
        LODOP.ADD_PRINT_TEXT(463, 113, 100, 20, "13725243671");
        LODOP.SET_PRINT_STYLEA(0, "FontSize", 7);
        LODOP.ADD_PRINT_TEXT(476, "10mm", 263, 20, "广州市白云区云城西路北今尚科技大厦A栋一楼\r\n");
        LODOP.SET_PRINT_STYLEA(0, "FontSize", 7);
        LODOP.ADD_PRINT_TEXT(501, "10mm", "20mm", 20, "马云");
        LODOP.SET_PRINT_STYLEA(0, "FontSize", 7);
        LODOP.ADD_PRINT_TEXT(501, 114, 100, 20, "88888888888888\r\n");
        LODOP.SET_PRINT_STYLEA(0, "FontSize", 7);
        LODOP.ADD_PRINT_TEXT(513, 38, 264, 20, "杭州阿里巴巴总部\r\n");

        LODOP.SET_PRINT_STYLEA(0, "FontSize", 7);
        LODOP.ADD_PRINT_RECT("141.68mm", "-1.01mm", "102mm", "40.01mm", 0, 1);
        LODOP.PREVIEW();
    }

    //发货
    function wuliu(d, check) {
        var id = check;
        var formValidEvent;
        var formValidInit = function () {
            var formValidData = [
                {
                    key: "LogisticsNo",
                    datatype: "*",
                    nullmsg: "不能为空哦",
                    errormsg: "不能为空哦"
                },
                {
                    key: "LogisticsCode",
                    datatype: "*",
                    nullmsg: "不能为空哦",
                    errormsg: "不能为空哦"
                },

            ];
            formValidEvent = $("#temfahou").formValid(formValidData);
        }
        var inintData = {
            LogisticsNo: "",
            LogisticsCode: "",
            LogisticsName: "",
            install: d,
            OrderNo: id
        };
        $("#temfahou").templateRender({ el: "fahou", data: inintData });//渲染模板，要先渲染才能获值
        formValidInit();

        $("#temfahou").on("click", "#btn-submit", function () { //保存按钮有添加和编辑
            if (!formValidEvent.check()) { return; }
            $("#temfahou").ajaxFormSubmit("order/shipments", {
                pass: function (d) {
                    $.msgSucceed(d.Errmsg);
                    setTimeout(function () {
                        window.location.reload();
                    }, 1500)
                    return
                },
                error: function (d) {
                    $.msgFall(d.Errmsg);
                }
            })
            return
        });

    }

    //打印
    function CreatePrintPage() {
        var pObj = $("#tem").find("tbody tr");
        var aObj = $("#tem2").find("tbody tr");
        var presentObj = $("#tem3").find("tbody tr");
        var top = 0;
        var sum = 0;
        LODOP = getLodop();
        LODOP.PRINT_INIT("送货订单");
        LODOP.SET_PRINT_STYLEA("FontName", "隶书");
        LODOP.SET_PRINT_STYLE("FontSize", 12);
        LODOP.ADD_PRINT_TEXT("10mm", "5mm", "140mm", "10mm", "订单编号：" + $(pObj[0]).find("td").first().html());
        LODOP.ADD_PRINT_TEXT("10mm", "70mm", "140mm", "10mm", "下单时间：" + $(pObj[0]).find("td").last().html());
        LODOP.ADD_PRINT_TEXT("20mm", "5mm", "105mm", "10mm", "产品名称");
        LODOP.ADD_PRINT_TEXT("20mm", "110mm", "15mm", "10mm", "数量");
        LODOP.ADD_PRINT_TEXT("20mm", "125mm", "20mm", "10mm", "金额");

        LODOP.ADD_PRINT_TEXT("25mm", "5mm", "140mm", "10mm", "-----------------------------------------------------------------");
        top = 25;
        $.each($(pObj), function (i, item) {
            LODOP.ADD_PRINT_TEXT((top + 5) + "mm", "5mm", "105mm", "10mm", $(this).find("td").eq(1).html() + "(" + $(this).find("td").eq(4).html() + ")");
            LODOP.SET_PRINT_STYLEA(0, "FontSize", 10);
            LODOP.ADD_PRINT_TEXT((top + 5) + "mm", "110mm", "15mm", "10mm", $(this).find("td").eq(2).html());
            LODOP.ADD_PRINT_TEXT((top + 5) + "mm", "125mm", "20mm", "10mm", $(this).find("td").eq(03).html());
            top = top + 5;
            sum = sum + parseFloat($(this).find("td").eq(03).html());
        });
        top = top + 5;
        LODOP.ADD_PRINT_TEXT(top + "mm", "5mm", "140mm", "10mm", "-----------------------------------------------------------------");
        top = top + 5;
        LODOP.ADD_PRINT_TEXT(top + "mm", "5mm", "140mm", "10mm", "合计：    " + sum + "元");
        if (presentObj.length > 0) {
            top = top + 5;
            LODOP.ADD_PRINT_TEXT(top + "mm", "5mm", "140mm", "10mm", "-----------------------------赠送产品----------------------------");
            $.each($(presentObj), function (i, item) {
                LODOP.ADD_PRINT_TEXT((top + 5) + "mm", "5mm", "105mm", "10mm", $(this).find("td").eq(0).html() + "(" + $(this).find("td").eq(1).html() + ")");
                LODOP.SET_PRINT_STYLEA(0, "FontSize", 10);
                LODOP.ADD_PRINT_TEXT((top + 5) + "mm", "110mm", "15mm", "10mm", $(this).find("td").eq(2).html());
                top = top + 5;
            });
            top = top + 5;
            LODOP.ADD_PRINT_TEXT(top + "mm", "5mm", "140mm", "10mm", "-----------------------------------------------------------------");
        }
        top = top + 15;
        LODOP.ADD_PRINT_TEXT(top + "mm", "5mm", "140mm", "10mm", "----------------------------收货人信息---------------------------");
        top = top + 5;
        LODOP.ADD_PRINT_TEXT(top + "mm", "5mm", "140mm", "10mm", "收货人姓名：" + $(aObj).first().find("td").eq(0).html());
        top = top + 5;
        LODOP.ADD_PRINT_TEXT(top + "mm", "5mm", "140mm", "10mm", "收货人电话：" + $(aObj).first().find("td").eq(1).html());
        top = top + 5;
        var address = $(aObj).first().find("td").eq(3).html() + $(aObj).first().find("td").eq(4).html() + $(aObj).first().find("td").eq(5).html();
        LODOP.ADD_PRINT_TEXT(top + "mm", "5mm", "140mm", "10mm", "收货人地址：" + address.replace(',', '').replace(',', '').replace(',', ''));
        top = top + 5;
        LODOP.ADD_PRINT_TEXT(top + "mm", "5mm", "140mm", "10mm", "收货人详细地址：" + $(aObj).first().find("td").eq(6).html());
        LODOP.PREVIEW();
    }

    function openDetail(o) {  //弹出订单详情

        $.layrePage({  //弹出
            area: ["90%", "800px"],
            title: "订单详情",
            offset: "6px",
            content: template("tp-order-detail", {})
        });

        $.http.json("order/find", { OrderNo: o }, { //发出请求
            pass: function (d) {

                $("#layre-order-detail #tem table>tbody").append(template("det-temp", { //订单详情
                    list: d
                }));
                $("#layre-order-detail #tem1 table>tbody").append(template("com-temp", {//订单产品
                    list: d
                }));
                $("#layre-order-detail #tem2 table>tbody").append(template("com-temp2", {//收货地址
                    list: d
                }));
                $("#layre-order-detail #tem3 table>tbody").append(template("com-temp3", {//赠送产品
                    list: d
                }));
            },
            error: function (d) {
                console.log(d);
            }
        });

    }
</script>